﻿namespace ManagedChangeJournal.Native.Journal
{
    using System.Runtime.InteropServices;

    /// <summary>
    /// USN_RECORD structure for Change Journal version 2.0 software
    /// </summary>
    [StructLayout(LayoutKind.Sequential)]
    struct JournalEntry
    {
        /// <summary>
        /// The total length of the entry in bytes, including the file name.
        /// </summary>
        public uint RecordLength;
        /// <summary>
        /// The major version of the journal the record has been read from.
        /// If this value is higher than expected, the native UsnRecord structure has changed 
        /// dramatically and the only reliable members are RecordLength, MajorVersion and MinorVersion.
        /// </summary>
        public ushort MajorVersion;
        /// <summary>
        /// The minor version of the journal the record has been read from.
        /// If this value is higher than expected, the native UsnRecord structure has changed
        /// slighty, meaning further members have been appended to the previous structure and every 
        /// member of the currently compiled managed structure can be considered reliable.
        /// </summary>
        public ushort MinorVersion;
        /// <summary>
        /// The reference number of the file or directory associated with this record.
        /// </summary>
        public ulong FileReferenceNumber;
        /// <summary>
        /// The reference number of the parent of the file or directory associated with this record.
        /// </summary>
        public ulong ParentFileReferenceNumber;
        /// <summary>
        /// The Usn associated with this record.
        /// A Usn value is ultimately the offset of the associated record within the journal.
        /// </summary>
        public long USN;
        /// <summary>
        /// 
        /// </summary>
        public long TimeStamp;
        /// <summary>
        /// 
        /// </summary>
        public uint Reason;
        /// <summary>
        /// 
        /// </summary>
        public uint SourceInfo;
        /// <summary>
        /// 
        /// </summary>
        public uint SecurityId;
        /// <summary>
        /// 
        /// </summary>
        public uint FileAttributes;
        /// <summary>
        /// 
        /// </summary>
        public ushort FileNameLength;
        /// <summary>
        /// 
        /// </summary>
        public ushort FileNameOffset;
    }
}
